package cn.stylefeng.guns.modular.biz.controller;

import cn.stylefeng.guns.modular.biz.entity.PrWeightRecods;
import cn.stylefeng.guns.modular.biz.pojo.request.PrWeightRecodsRequest;
import cn.stylefeng.guns.modular.biz.service.PrWeightRecodsService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * 进场煤分摊记录控制器
 *
 * @author 张朋飞
 * @since 2024/10/11 16:57
 */
@RestController
@ApiResource(name = "进场煤分摊记录")
public class PrWeightRecodsController {

    @Resource
    private PrWeightRecodsService prWeightRecodsService;

    /**
     * 添加进场煤分摊记录
     *
     * @author 张朋飞
     * @since 2024/10/11 16:57
     */
    @PostResource(name = "添加进场煤分摊记录", path = "/prWeightRecods/add")
    public ResponseData<PrWeightRecods> add(@RequestBody @Validated(PrWeightRecodsRequest.add.class) PrWeightRecodsRequest prWeightRecodsRequest) {
        prWeightRecodsService.add(prWeightRecodsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 删除进场煤分摊记录
     *
     * @author 张朋飞
     * @since 2024/10/11 16:57
     */
    @PostResource(name = "删除进场煤分摊记录", path = "/prWeightRecods/delete")
    public ResponseData<?> delete(@RequestBody @Validated(PrWeightRecodsRequest.delete.class) PrWeightRecodsRequest prWeightRecodsRequest) {
        prWeightRecodsService.del(prWeightRecodsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 批量删除进场煤分摊记录
     *
     * @author 张朋飞
     * @since 2024/10/11 16:57
     */
    @PostResource(name = "批量删除进场煤分摊记录", path = "/prWeightRecods/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) PrWeightRecodsRequest prWeightRecodsRequest) {
        prWeightRecodsService.batchDelete(prWeightRecodsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑进场煤分摊记录
     *
     * @author 张朋飞
     * @since 2024/10/11 16:57
     */
    @PostResource(name = "编辑进场煤分摊记录", path = "/prWeightRecods/edit")
    public ResponseData<?> edit(@RequestBody @Validated(PrWeightRecodsRequest.edit.class) PrWeightRecodsRequest prWeightRecodsRequest) {
        prWeightRecodsService.edit(prWeightRecodsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 查看进场煤分摊记录详情
     *
     * @author 张朋飞
     * @since 2024/10/11 16:57
     */
    @GetResource(name = "查看进场煤分摊记录详情", path = "/prWeightRecods/detail")
    public ResponseData<PrWeightRecods> detail(@Validated(PrWeightRecodsRequest.detail.class) PrWeightRecodsRequest prWeightRecodsRequest) {
        return new SuccessResponseData<>(prWeightRecodsService.detail(prWeightRecodsRequest));
    }

    /**
     * 获取进场煤分摊记录列表
     *
     * @author 张朋飞
     * @since 2024/10/11 16:57
     */
    @GetResource(name = "获取进场煤分摊记录列表", path = "/prWeightRecods/list")
    public ResponseData<List<PrWeightRecods>> list(PrWeightRecodsRequest prWeightRecodsRequest) {
        return new SuccessResponseData<>(prWeightRecodsService.findList(prWeightRecodsRequest));
    }

    /**
     * 获取进场煤分摊记录列表（带分页）
     *
     * @author 张朋飞
     * @since 2024/10/11 16:57
     */
    @GetResource(name = "获取进场煤分摊记录列表（带分页）", path = "/prWeightRecods/page")
    public ResponseData<PageResult<PrWeightRecods>> page(PrWeightRecodsRequest prWeightRecodsRequest) {
        return new SuccessResponseData<>(prWeightRecodsService.findPage(prWeightRecodsRequest));
    }

}
